#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <unistd.h>
#include <pthread.h>

void* routine(void* args)
{
    std::string name = static_cast<const char*>(args);
    while(true)
    {
        std::cout << "我们是新线程,我的名字是: " << name << std::endl;
        sleep(1);
    }
    return 0;
}

int main()
{
    pthread_t tid;
    int n = pthread_create(&tid,nullptr,routine,(void*)"thread-1");
    if(n != 0)
    {
        std::cout << "create thread error: " << strerror(n) << std::endl;
        return 1;
    }
    while(true)
    {
        std::cout << "我们是主线程..." << std::endl;
        sleep(1);
    }
    return 0;
}



